﻿using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Internal;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CADDemo2025
{
    public class Command0225
    {
        [CommandMethod("Demo0225")]
        public void Demo0225()
        {
            if (!UmUserMethod.SelectEntities(out List<Entity> ents)) return;
            string blockName = DateTime.Now.ToString("yyyyMMddHHmmss");
            if (!BmBlcokMethod.CreatBlock(ents, blockName, new Point3d(), out BlockTableRecord btr)) return;
            System.Drawing.Bitmap bitmap = System.Drawing.Bitmap.FromHbitmap(Utils.GetBlockImage(btr.ObjectId, 300, 300, Color.FromRgb(255, 0, 0)));
            bitmap.Save(@"C:\Users\Administrator\Desktop\新建文件夹 (2)\111.png");
            btr.ObjectId.DeleteBlock();
        }
    }
}
